package com.mmy.service.impl.restaurant;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.mmy.dao.restaurant.TRestaurantBaseRepository;
import com.mmy.dao.restaurant.VRestaurantBaseRepository;
import com.mmy.domain.restaurant.VRestaurantBase;
import com.mmy.mapper.RestDao;
import com.mmy.service.ServiceCommon;
import com.mmy.service.restaurant.RestaurantBaseService;

@Service
public class RestaurantBaseServiceImpl implements RestaurantBaseService {

	@Autowired
	TRestaurantBaseRepository tRestaurantBaseRepository;
	@Autowired
	VRestaurantBaseRepository vRestaurantBaseRepository;
	@Autowired
	ServiceCommon common;
	@Autowired
	RestDao restDao;
	

	/**
	 * 函数功能说明：前台景点菜单显示信息 分页
	 *
	 * @param 参数说明
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人hanxl
	 * @param pageSize
	 * @param pageNumber
	 * @param iZoneID
	 * @param strScenicName
	 * @date 创建日期2021.01.14
	 */
	public HashMap<String, Integer> mapFrontRestBase(String pageNumber, String pageSize, List<Integer> lstRestID) {
		HashMap<String, Integer> mapPage = common.getPage(pageNumber, pageSize,
				tRestaurantBaseRepository.countSearch(lstRestID));

		return mapPage;
	}

	/**
	 * 函数功能说明： 进入后台景区电子票信息页面查询景点详情信息
	 *
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人 hanxl
	 * @date 创建日期 2020.12.24
	 */

	public VRestaurantBase findByRestaurantID(String strRestaurantID) {
		int iRestaurantID = Integer.valueOf(strRestaurantID);
		return vRestaurantBaseRepository.findByRestaurantID(iRestaurantID);
	}
	
	/**
	  * @descr 餐馆级联选择器 
	  * @param iZoneID
	  * @return JSON
	  * @throws 
	  * @author liys
	  * @date 2021-6-18
	 */
	public String restSelect(int iZoneID) {
		
		List<Map<String,Object>> scenicList = restDao.getRestsByZone(iZoneID);
		for (Map<String, Object> item : scenicList) {
			item.put("children", restDao.getPlansByBaseID((int) item.get("value")));
		}
		return JSONObject.toJSONString(scenicList);
	} 
}
